{include file="./public/footer" /}
{include file="./public/menu" /}
<!--引入kindeditor编辑器-->
<script src="__STATIC__/Admin/kindeditor/kindeditor-all.js"></script>
<!--/sidebar-->
<div class="main-wrap">

    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="/admin.php">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="/admin.php/plane/lists">机票管理</a><span class="crumb-step">&gt;</span><span>新增机票</span></div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <form  id="andy_form"  name="myform" enctype="multipart/form-data">
                <table class="insert-tab" width="100%">
                    <tbody>
                    <tr>
                        <th width="120"><i class="require-red">*</i>所属航线：</th>
                        <td>
                            <select name="plane_id"  class="required" style="width: 180px">
                                <option value="0">请选择</option>
                                {volist name="plane" id="plane"}
                                    <option value="{$plane.id}">{$plane.title}</option>
                                {/volist}
                            </select>
                        </td>
                    </tr>
                    <!--<div class="control-group error" id="fruit-spec" style="margin-left: 180px">-->
                        <!--<div class="controls control-input">-->
                            <!--<input type="text" onclick="fPopCalendar(event,this,this)" readonly="readonly" name="date" value="">-->
                            <!--<input class="common-text required"  name="price" size="10"  type="text">-->
                            <!--<button class="btn btn-primary" id="andy-button-spec-add" type="button">添加航班</button>-->
                        <!--</div>-->
                    <!--</div>-->
                    <tr>
                        <th width="120"><i class="require-red">*</i>航班日期：</th>
                        <td>
                            <input type="text" onclick="fPopCalendar(event,this,this)" readonly="readonly" name="date" value="">
                        </td>
                    </tr>

                    <tr>
                        <th width="120"><i class="require-red">*</i>航班价格：</th>
                        <td>
                            <input type="text"  name="price" value="">
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>机票状态：</th>
                        <td>
                            &nbsp;<input type="radio"  value="1" size="85" name="status" class="common-text" checked>正常&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;<input type="radio" value="0" name="status" size="85" class="commont-text">代审
                        </td>
                    </tr>


                    <tr>
                        <th></th>
                        <td>
                            <input class="btn btn-primary btn6 mr10" id="andy_line_submit" value="提交" type="button">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                        </td>
                    </tr>
                    </tbody></table>
            </form>
        </div>
    </div>

</div>
<!--/main-->
<script>
    KindEditor.ready(function(K) {
        window.editor = K.create('#kindeditor_id',{
            uploadJson : '/admin.php/image/kindUpload',
            afterBlur: function(){this.sync();}
        });
    });

    var SCOPE = {
        'save_url' : '/admin.php/plane/planeadd',
        'jump_url' : '/admin.php/plane/planelists',
        'ajax_upload_swf' : "__STATIC__/Admin/uploadify/uploadify.swf",
        'ajax_upload_image_url' : '/admin.php/image/ajaxUploadImage',
    }
    //添加航班
    $('#andy-button-spec-add').on('click',function(){
        $('#fruit-spec').prepend("<div class='controls control-input'> <input type='text' onclick='fPopCalendar(event,this,this)' readonly='readonly' name='date' value=''> <input class='common-text required'  name='price' size='10'  type='text'><button class='btn btn-danger' id='andy-button-spec-del' type='button'>删除航班</button></div>");
    });
    //删除航班
    $("body").on('click','.btn-danger',function(){
        $(this).parent(".controls").remove();
    });
</script>
<script>

    //添加
    $("#andy_line_submit").click(function(){
        //获取商品属性
        var config = [];
        $('input[name="config"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
            config.push($(this).val());
        });
        //获取轮播图
        obj = $('input[name="img"]');
        var img = [];
        for(var i = 0; i < obj.length; i++){
            img.push(obj[i].value);
        }
        //获取剩余的信息
        var data = $("#andy_form").serializeArray();
        var postData = {};
        $(data).each(function(){
            postData[this.name] = this.value;
        });
        //赋值
        postData.config = config;
        postData.img = img;

        //获取提交地址
        var url = SCOPE.save_url;
        //获取返回地址
        var jump_url = SCOPE.jump_url;
        $.post(url,postData,function(result){
            if(result.status == 1) {
                //成功
                return dialog.success(result.message,jump_url);
            }else if(result.status == 0) {
                // 失败
                return dialog.error(result.message);
            }
        },'JSON');
    });
</script>
{include file="./public/bottom" /}